/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data.logic;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.util.Vector;

/**
 *
 * @author Jonas
 */
public class VillageLogic {

    private Dimension dimension;
    private Square[][] buildingSpots = null;

    public VillageLogic() {
        //Number of spots width x height 
        dimension = new Dimension(15, 11);
        init();
    }

    public void init() {

        buildingSpots = null;
        buildingSpots = new Square[(int) getDimension().getWidth()][(int) getDimension().getHeight()];
        SquareType grasSquare = new SquareType("Gras", true, new Color(81, 120, 63));

        for (int j = 0; j < getDimension().getHeight(); j++) {
            for (int i = 0; i < getDimension().getWidth(); i++) {
                buildingSpots[i][j] = new Square(grasSquare, new Point(i, j));
            }
        }
    }

    public void drawBuildings(Vector<Square> buildings) {

        for (Square v : buildings) {
            buildingSpots[v.getPosition().x][v.getPosition().y] = v;
        }
    }

    public void destructBuilding(Point buildingPosition) {
        SquareType grasSquare = new SquareType("Gras", true, new Color(81, 120, 63));
        buildingSpots[buildingPosition.x][buildingPosition.y] = new Square(grasSquare, new Point(buildingPosition.x, buildingPosition.y));
    }

    public Square[][] getVillageSpots() {
        return buildingSpots;
    }

    public Dimension getDimension() {
        return dimension;
    }

    public void setDimension(Dimension dimension) {
        this.dimension = dimension;
    }

    public void drawNewBuilding(Square v) {

        buildingSpots[v.getPosition().x][v.getPosition().y] = v;
    }
}


